<?php

namespace app\common\business\lib;

class Str
{
    //生成随机字符串
    public function createToken($str)
    {
        $tokenSalt = md5(uniqid(md5(microtime(true)), true));

        return sha1($tokenSalt.$str);
    }

    //生成随机字符串
    public function salt($length)
    {
        $str = null;
        $strPol = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
        $max = strlen($strPol) - 1;

        for ($i = 0; $i < $length; ++$i) {
            $str .= $strPol[rand(0, $max)];
        }
    }
}
